package homework.five;

public class PrimeNumberTester extends Thread{
    private Long number;
    private Long number1;
    public PrimeNumberTester(Long number, Long number1){
        this.number = number;
        this.number1 = number1;
    }
    public boolean isPrimeNumber(Long number){// 素数判断
        Long sqrNumber = (new Double(Math.sqrt(number))).longValue();
        for(Long i = 2l; i <= sqrNumber; i++){
            if(number % i == 0){
                return false;
            }
        }
        return true;
    }
    public void run(){
        Long count = 0l;
        Long count1 = 0l;
        for(Long i = 2l; i <= number; i++){
            if(this.isPrimeNumber(i)){
                count++;
            }
        }
        for(Long i = 2l; i <= number1; i++){
            if(this.isPrimeNumber(i)){
                count1++;
            }
        }
        System.out.println(Thread.currentThread().getName() + "计算结果：小于：" + number
                + "大于："+ number1 + "的质数个数：" + (count1 - count));
    }
}
